Skip to content

fix(relay): multi-value #h filters must not narrow to first channel (#4579) - #4624

Open
IgorGanapolsky wants to merge 1 commit into
block:mainfrom
IgorGanapolsky:fix/multi-h-filter-4579-dco
Open

fix(relay): multi-value #h filters must not narrow to first channel (#4579)#4624
IgorGanapolsky wants to merge 1 commit into
block:mainfrom
IgorGanapolsky:fix/multi-h-filter-4579-dco

Conversation

@IgorGanapolsky

Copy link
Copy Markdown

Summary

Fixes #4579: a filter with multiple #h channel values was silently answered as if it named only the lexicographically first channel.

Supersedes #4598 (same fix; that PR failed DCO — this commit is Signed-off-by).

Failure (before)

extract_channel_id_from_filter returned the first parseable UUID from #h. nostr::Filter stores generic_tags in a sorted set, so multi-channel queries always collapsed to the smallest id. SQL then scoped to that one channel; the Rust post-filter can only remove rows, never restore dropped channels.

Concrete impact: Desktop's global Workflows view batches kind:30620 with every member channel in #h. Workflows living in any channel other than the first alphabetically never appeared.

After

#h values SQL scope
none unscoped (access scope may inject full accessible set)
one distinct channel_id = that id
multiple distinct channel_id = None, channel_ids = all of them

apply_access_scope_to_query intersects a pre-set multi-#h list with the caller's accessible channels instead of replacing it with the full set.

Verification

cargo test -p buzz-relay --lib handlers::req::tests

51 passed (full handlers::req::tests module), including:

  • extract_channel_id_from_filter_multi_h_returns_none
  • filter_to_query_params_multi_h_sets_channel_ids_not_first_only
  • apply_access_scope_intersects_multi_h_channel_ids

…lock#4579)

extract_channel_id_from_filter returned the first parseable #h UUID.
nostr::Filter stores generic_tags in a sorted set, so multi-channel
queries (e.g. desktop Workflows kind:30620 over every member channel)
were silently scoped to the lexicographically smallest id and dropped
every other channel from SQL.

- channel_scope_from_filter: one id → channel_id; many → channel_ids
- apply_access_scope intersects multi-#h lists instead of replacing them
- unit tests pin the fail-before / pass-after behavior

Signed-off-by: Igor Ganapolsky <201209+IgorGanapolsky@users.noreply.github.com>
@IgorGanapolsky
IgorGanapolsky requested a review from a team as a code owner August 3, 2026 22:09
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-value #h filters silently narrow to the lexicographically first channel, dropping all others

1 participant